package office.action.hr;

import java.util.List;

import office.action.hr.form.CarriageManageForm;
import office.service.hr.ICarriageManageService;

import platform.common.action.BaseAction;
import platform.util.Util;;

/**
 * 车辆维护
 * @author ibmsz
 *
 */
public class CarriageManageAction extends BaseAction{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private ICarriageManageService carriageManageService;
	private CarriageManageForm objctForm;
	private String id;
	@SuppressWarnings("unchecked")
	private List wrapperList;
	@SuppressWarnings("unchecked")
	private List carriageSateList;
	

	public String carriageManageList()throws Exception{
		wrapperList = carriageManageService.getCarriageManageList();
		return "showList";
	}
	/**
	 * 跳转到编辑页面
	 * @return
	 * @throws Exception
	 */
	public String gotoAdd()throws Exception{
		//carriageTypeList = Util.parsePropertiesReturnList("office","carriageType.size");
		carriageSateList = Util.parsePropertiesReturnList("office","carriageSateNew.size");
		return "gotoEdit";
	}
	
	/**
	 * 跳转到编辑页面
	 * @return
	 * @throws Exception
	 */
	public String gotoEdit()throws Exception{
		//carriageTypeList = Util.parsePropertiesReturnList("office","carriageType.size");
		//carriageSateList = Util.parsePropertiesReturnList("office","carriageSate.size");
		objctForm = carriageManageService.getById(id);
		return "gotoEdit";
	}
	/**
	 * 添加或编辑数据
	 * @return
	 * @throws Exception
	 */
	public String editData() throws Exception{
		try {
			carriageManageService.editCarriageManage(objctForm);
			if(null==objctForm.getId() || ("").equals(objctForm.getId())){
				this.getAjaxMessagesJson().setMessage(true, "", "新建成功");
			}else{
				this.getAjaxMessagesJson().setMessage(true, "", "编辑成功");
			}
			
		} catch (Exception e) {
			this.handleException(e);
		}
		return RESULT_AJAXJSON;
	}
	/**
	 * 初始化可用操作
	 * @return
	 * @throws Exception
	 */
	public String gotoEditXml()throws Exception{
		objctForm = carriageManageService.getById(id);
		return "editXml";
	}
	/**
	 * 初始化删除
	 * @return
	 * @throws Exception
	 */
	public String gotoDel()throws Exception{
		return "gotoDel";
	}
	/**
	 * 删除
	 * @return
	 * @throws Exception
	 */
	public String delData()throws Exception{
		try {
			carriageManageService.deleteById(id);
			this.getAjaxMessagesJson().setMessage(true, "", "删除成功");
			
		} catch (Exception e) {
			this.handleException(e);
		}
		return RESULT_AJAXJSON;
	}
	/**
	 * 初始化修改状态
	 * @return
	 * @throws Exception
	 */
	public String gotoChangeSate() throws Exception{
		return "gotoChangeSate";
	}
	
	public String changeState() throws Exception{
		try {
			carriageManageService.changeState(objctForm);
			this.getAjaxMessagesJson().setMessage(true, "", "状态修改成功!");
			
		} catch (Exception e) {
			this.handleException(e);
		}
		return RESULT_AJAXJSON;
	}
	
	public ICarriageManageService getCarriageManageService() {
		return carriageManageService;
	}
	public void setCarriageManageService(
			ICarriageManageService carriageManageService) {
		this.carriageManageService = carriageManageService;
	}
	public CarriageManageForm getObjctForm() {
		return objctForm;
	}
	public void setObjctForm(CarriageManageForm objctForm) {
		this.objctForm = objctForm;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	@SuppressWarnings("unchecked")
	public List getWrapperList() {
		return wrapperList;
	}
	@SuppressWarnings("unchecked")
	public void setWrapperList(List wrapperList) {
		this.wrapperList = wrapperList;
	}
	@SuppressWarnings("unchecked")
	public List getCarriageSateList() {
		return carriageSateList;
	}
	@SuppressWarnings("unchecked")
	public void setCarriageSateList(List carriageSateList) {
		this.carriageSateList = carriageSateList;
	}
	
	
}
